package org.mercworks.knight.util.modelImporter;

import java.io.EOFException;
import java.io.InputStream;
import java.io.ObjectInputStream;

import org.mercworks.knightgame.model.KnightGameModel;

public class ImportModelUtil
{
	public KnightGameModel importModelFromFile(String strFileName)
	{
		KnightGameModel model = new KnightGameModel();
		InputStream inputStream = this.getClass().getResourceAsStream(strFileName);
		
		try
		{
			ObjectInputStream objectIn = new ObjectInputStream (inputStream);
			model = (KnightGameModel)objectIn.readObject();
		}
		catch(EOFException eofe)
		{
			System.out.println("PREMATURE END OF FILE");
			eofe.printStackTrace();
		}
		catch(Exception ex)
		{
			ex.printStackTrace();
		}
		
		return model;
	}
}
